<template>
  <bpm-toolbar :bpmformdata="formData">
    <!-- <template #btn-left>
  <button @click="closeWebView">关闭</button>
</template> -->
    <!-- <template #btn-right>
<button>right</button>
</template>   -->
  </bpm-toolbar>
  <div class="wrap">
    <div class="form">
      <div class="center bg-white">
        <bpm-basicinfo :bpmformdata="formData"></bpm-basicinfo>

        <userpick
          :parmdialog="parmdialog"
          v-on:closedialog="closedialog"
          v-on:requseturl="userpickCallBack"
        >
        </userpick>
        <bpm-attachments :bpmformdata="formData"></bpm-attachments>
        <bpm-remarks :bpmformdata="formData"></bpm-remarks>
        <bpm-processinfo :bpmformdata="formData">
          <!-- <template #sub="defaultProps" >
                    <button>sub {{defaultProps.isMobile}}</button>
                  </template>  -->
        </bpm-processinfo>

        <bpm-processcomment :bpmformdata="formData"></bpm-processcomment>
      </div>
    </div>

  </div>
</template>

<script>
// import * as XLSX from "xlsx";
import { UserFilled, Upload, MoreFilled } from "@element-plus/icons-vue";
import { ElMessage, ElLoading, ElMessageBox } from "element-plus";
import { reactive, onMounted, ref, getCurrentInstance } from "vue";
/* eslint-disable no-unused-vars */
export default {
  name: "App",
  components: {
    UserFilled,
    Upload,
    MoreFilled,
  },
  data() {
    return {
      ShowConentZCJ: true,
      ShowConentQXBG: false,
      ShowConentONBG: false,
      ShowConentZSC: false,
      //邮箱组变量
      memberList: "组成员：",
      dialogFormVisible: false,
      //组账号前缀
      prependList: "DL.",
      memberList: "组成员：",
      //组成员表格数据
      tableData: [
        {
          e_mail: "wangyichen@wuxibiologics.com",
          name: "王一晨",
          position: "前端工程师",
          department: "开发",
        },
        {
          e_mail: "hezhenhang@wuxibiologics.com",
          name: "何振航",
          position: "后端工程师",
          department: "开发",
        },
        {
          e_mail: "songzhilong@wuxibiologics.com",
          name: "宋志龙",
          position: "架构师",
          department: "解决方案部",
        },
        {
          e_mail: "zhangning@wuxibiologics.com",
          name: "张宁",
          position: "项目经理",
          department: "解决方案部",
        },
        {
          e_mail: "wangyong@wuxibiologics.com",
          name: "王勇",
          position: "前端工程师",
          department: "开发",
        },
      ],
      //流程组件数据
      // formData: KStarForm.vmFormData,
      hideFormSubject: false,
      cancelflag: "false",
      /*--------申请人信息--------*/
      isAgentDisable: true,
      /*--------申请设备信息--------*/
      isBudgetNumberHidden: true, //预算号是否显示
      /*--------部门采购信息--------*/
      isReportSPASoftwareListsHidden: false, //部门采购信息
      isScoopelHaveValue: false, //部门采购信息-----附件是否可以编辑      默认不可编辑【false】
      /*--------软件清单记录报表--------*/
      IsDetailSPASoftwareListsAdd: true,
      //弹框
      DioTitle: "编辑信息",
      editT: false, //编辑弹出框
      formlist: {
        //组类别下拉框数据
        groupCategory: [
          {
            value: 1,
            label: "邮件组",
          },
          {
            value: 2,
            label: "权限组",
          },
          {
            value: 3,
            label: "公司级全员邮件组",
          },
        ],
        //申请类别下拉框数据
        groupTypeOptions: [
          {
            value: 1,
            label: "组创建",
          },
          {
            value: 2,
            label: "权限变更",
          },
          {
            value: 3,
            label: "Owner变更",
          },
          {
            value: 4,
            label: "组删除",
          },
        ],
        //邮件组账号提醒数据
        groupEmailOptions: [
          {
            value: "1",
            label: "wangyichen@wuxibiologics.com",
          },
          {
            value: "2",
            label: "zhangning@wuxibiologics.com",
          },
          {
            value: "3",
            label: "hezhenhang@wuxibiologics.com",
          },
        ],
        groupFrom: {
          groupType: 1,
          groupCategory: 1,
          groupAccount: "",
          groupName: "",
          Owner: "张宁",
        },
      },
      form: {
        Site: "",
        Depcname: "",
        SoftwareType: "",
        SoftwareName: "",
        SoftwareVersion: "",
        OriginalSoftwareManufacturer: "",
        InstallationPackage: "",
        Charge: "",
        LicenseQuotas: "",
        FreeQuotas: "0",
        UsedQuotas: "0",
        RemainingAvailableQuotas: "",
        PurchaseTime: "",
        ExpireDate: "",
        Availability: "",
        LicenseKey: "",
        License: "",
        LicenseAnnex: "",
        AttachmentFileId: "",
        AttachmentDownloadUrl: "",
        AttachmentUploadedDate: "",
        AttachmentUploader: "",
        Disable: "",
        Comments: "",
      }, //弹出窗数据
      scope_Edit: {}, //记录编辑时选中的行
      file_Temp: {
        LicenseAnnex: "",
        AttachmentFileId: "",
        AttachmentDownloadUrl: "",
        AttachmentUploadedDate: "",
        AttachmentUploader: "",
      }, //记录临时附件

      siteArr: [], //	数据源改成公司
      depcnameArr: [], //	部门
      softwareTypeArr: [], //	软件类型
      availabilityArr: [], //	软件有效性
      whetherArr: [
        { Name: "是", EName: "Yes", Code: "1" },
        { Name: "否", EName: "No", Code: "2" },
      ], //	是否
      reportSoftwareLists: [], // 软件清单List
      currentreportSoftwareList: [], // 当前搜索reportSoftwareLists数据
      temporaryChecked: {}, // 暂存选中的软件
      SoftwareTypeSearchInput: "", // 弹窗搜索关键字
      SoftwareNameSearchInput: "", // 弹窗搜索关键字
      dialogPageSize: 5, // 弹框分页显示数量
      currentPage: 1, // 当前页
      dialogAssetNumberFlag: false, // list弹窗flag
      langu: "cn",
      parmdialog: {
        dialogvisible: false,
        clicktype: "",
        type: "",
        ctype: "",
        title: "选人控件",
        multiplelimit: false,
      },
      loading: false, //上传附件加载框
    };
  },
  created: function () {
    var that = this;
    // KStarForm.vmFormData = this.formData;
    // KStarForm.init(that,"CommonForm");
  },
  methods: {
    /*----------申请人信息----------*/
    //新增方法
    onAdd() {
      this.dialogFormVisible = true;
      console.log(this.dialogFormVisible);
    },
    //删除提醒方法
    det(sum, index) {
      this.$confirm(sum, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "提交成功!",
          });
          this.tableData.splice(index, 1);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    //取消
    handleCancel() {
      this.dialogFormVisible = false;
    },
    //添加数据
    onAddItemFun() {
      this.tableData.push({
        e_mail: this.onAddItem.email,
        name: this.onAddItem.name,
        position: this.onAddItem.position,
        department: this.onAddItem.department,
      }),
        (this.onAddItem.email = ""),
        (this.onAddItem.name = ""),
        (this.onAddItem.position = ""),
        (this.onAddItem.department = ""),
        (this.dialogFormVisible = false);
    },
    //下载通用模板的方法
    expt() {
      this.$refs.downloadTemplate.dispatchEvent(new MouseEvent("click"));
    },
    //批量上传
    handleChange(file, fileList) {
      this.fileTemp = file.raw;
      console.log(this.fileTemp, 111111111111111);
      if (this.fileTemp) {
        if (
          this.fileTemp.type ==
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
          this.fileTemp.type == "application/vnd.ms-excel"
        ) {
          this.importfxx(this.fileTemp);
        } else {
          this.$message({
            type: "warning",
            message: "附件格式错误，请删除后重新上传！",
          });
        }
      } else {
        this.$message({
          type: "warning",
          message: "请上传附件！",
        });
      }
    },
    handleExceed() {
      this.$message({
        type: "warning",
        message: "超出最大上传文件数量的限制！",
      });
      return;
    },
    handleRemove(file, fileList) {
      this.fileTemp = null;
    },
    importfxx(obj) {
      let _this = this;
      let inputDOM = this.$refs.inputer;
      // 通过DOM取文件数据
      this.file = event.currentTarget.files[0];
      var rABS = false; //是否将文件读取为二进制字符串
      var f = this.file;
      var reader = new FileReader();
      //if (!FileReader.prototype.readAsBinaryString) {
      FileReader.prototype.readAsBinaryString = function (f) {
        var binary = "";
        var rABS = false; //是否将文件读取为二进制字符串
        var pt = this;
        var wb; //读取完成的数据
        var outdata;
        var reader = new FileReader();
        reader.onload = function (e) {
          var bytes = new Uint8Array(reader.result);
          var length = bytes.byteLength;
          for (var i = 0; i < length; i++) {
            binary += String.fromCharCode(bytes[i]);
          }
          // var XLSX = require("xlsx");
          if (rABS) {
            wb = XLSX.read(btoa(fixdata(binary)), {
              //手动转化
              type: "base64",
            });
          } else {
            wb = XLSX.read(binary, {
              type: "binary",
            });
          }
          outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
          //outdata就是你想要的东西
          console.log(this.tableData, "aaaaaa");
          //此处可对数据进行处理
          let arr = [];
          outdata.map((v) => {
            let obj = {};
            obj.e_mail = v["员工邮箱"];
            obj.name = v["员工姓名"];
            obj.position = v["职位"];
            obj.department = v["所属部门"];
            arr.push(obj);
          });
          _this.da = arr;
          _this.dalen = arr.length;
          _this.tableData = _this.da;
          console.log(_this.tableData);
          return this.tableData;
        };
        reader.readAsArrayBuffer(f);
      };
      if (rABS) {
        reader.readAsArrayBuffer(f);
      } else {
        reader.readAsBinaryString(f);
      }
    },
    //申请类别是否显示方法
    SelecGroupType(item) {
      if (item.value == 1) {
        this.ShowConentZCJ = true;
        this.ShowConentQXBG = false;
        this.ShowConentONBG = false;
        this.ShowConentZSC = false;
        this.header = "组创建";
      } else if (item.value == 2) {
        this.ShowConentZCJ = false;
        this.ShowConentQXBG = true;
        this.ShowConentONBG = false;
        this.ShowConentZSC = false;
        this.header = "权限变更";
      } else if (item.value == 3) {
        this.ShowConentZCJ = false;
        this.ShowConentQXBG = false;
        this.ShowConentONBG = true;
        this.ShowConentZSC = false;
        this.header = "Owner变更";
      } else if (item.value == 4) {
        this.ShowConentZCJ = false;
        this.ShowConentQXBG = false;
        this.ShowConentONBG = false;
        this.ShowConentZSC = true;
        this.header = "组删除";
      }
    },
    /*----------申请人信息----------*/
    getApplicantInformationOfBadge: function (val) {
      var userBadge = val;
      var _this = this;
      axios
        .post(
          KStarForm.bpmBaseUrl + "/Purchase/PurchaseIndex/SearchUser?badge=" + userBadge
        )
        .then(function (res) {
          var userInfo = eval(res.data.data);
          KStarForm.vmFormData.vmFormContent.ApplicantBadge = userInfo[0].Badge; // 工号
          KStarForm.vmFormData.vmFormContent.ApplicantAccount = userInfo[0].UserAccount; // 工号
          KStarForm.vmFormData.vmFormContent.Applicant = userInfo[0].UserName; // 申请人
          KStarForm.vmFormData.vmFormContent.Floor = userInfo[0].userfloor; // 楼号
          KStarForm.vmFormData.vmFormContent.Room = userInfo[0].userroom; // 房间号
          KStarForm.vmFormData.vmFormContent.GroupLeader = userInfo[0].groupleader; // 直属领导
          KStarForm.vmFormData.vmFormContent.GroupLeaderBadge =
            userInfo[0].groupleaderBadge; // 直属领导Badge
          KStarForm.vmFormData.vmFormContent.Jobcname = userInfo[0].Position; // 职称
          KStarForm.vmFormData.vmFormContent.Site = userInfo[0].compid; // 公司

          if (userInfo[0].Costcentercode != "" && userInfo[0].Costcentercode != null) {
            KStarForm.vmFormData.vmFormContent.CostCenter = userInfo[0].Costcentercode; // 成本中心
          }
          if (userInfo[0].DeptName != "" && userInfo[0].DeptName != null) {
            KStarForm.vmFormData.vmFormContent.Depcname = userInfo[0].DeptName; // 部门
          }

          if (
            userInfo[0].Costcentercode == "" ||
            userInfo[0].Costcentercode == null ||
            userInfo[0].DeptName == "" ||
            userInfo[0].DeptName == null
          ) {
            // 成本中心
            axios
              .post(
                KStarForm.bpmBaseUrl +
                  "/AppicationForPurchase/Common/GetBUCode?badge=" +
                  userInfo[0].Badge
              )
              .then(function (res) {
                var costCenterInfo = eval(res.data.data);
                if (costCenterInfo.length > 0) {
                  var compid = userInfo[0].compid;
                  if (compid) {
                    axios
                      .post(
                        KStarForm.bpmBaseUrl +
                          "/AppicationForPurchase/Common/GetCodeToCName?cName=" +
                          encodeURIComponent(compid)
                      )
                      .then(function (res) {
                        var array = eval(res.data.data);
                        if (array.length > 0) {
                          if (
                            userInfo[0].Costcentercode == "" ||
                            userInfo[0].Costcentercode == null
                          ) {
                            KStarForm.vmFormData.vmFormContent.CostCenter =
                              array[0].Code + costCenterInfo[0].SAPCode; // 成本中心
                          }
                        } else {
                          if (
                            userInfo[0].Costcentercode == "" ||
                            userInfo[0].Costcentercode == null
                          ) {
                            KStarForm.vmFormData.vmFormContent.CostCenter =
                              costCenterInfo[0].SAPCode; // 成本中心
                          }
                        }
                      })
                      .catch(function (error) {
                        console.log(error);
                      });
                  } else {
                    if (
                      userInfo[0].Costcentercode == "" ||
                      userInfo[0].Costcentercode == null
                    ) {
                      KStarForm.vmFormData.vmFormContent.CostCenter =
                        costCenterInfo[0].SAPCode; // 成本中心
                    }
                  }
                  if (userInfo[0].DeptName == "" || userInfo[0].DeptName == null) {
                    KStarForm.vmFormData.vmFormContent.Depcname =
                      costCenterInfo[0].DepName; // 部门
                  }
                } else {
                  if (
                    userInfo[0].Costcentercode == "" ||
                    userInfo[0].Costcentercode == null
                  ) {
                    KStarForm.vmFormData.vmFormContent.CostCenter = ""; // 成本中心
                    if (KStarForm.vmFormData.vmUserLanguages == "en") {
                      var costCenterTip =
                        "The cost center is empty, please maintain it in the background";
                    } else {
                      var costCenterTip = "成本中心为空，请在后台维护";
                    }
                    ElMessage({
                      showClose: true,
                      message: costCenterTip,
                      type: "error",
                    });
                  }
                  if (userInfo[0].DeptName == "" || userInfo[0].DeptName == null) {
                    KStarForm.vmFormData.vmFormContent.Depcname = ""; // 部门
                    if (KStarForm.vmFormData.vmUserLanguages == "en") {
                      var DeptNameTip =
                        "The department is empty, please maintain it in the background";
                    } else {
                      var DeptNameTip = "部门为空，请在后台维护";
                    }
                    ElMessage({
                      showClose: true,
                      message: DeptNameTip,
                      type: "error",
                    });
                  }
                }
              })
              .catch(function (error) {
                console.log(error);
              });
          }
        })
        .catch(function (error) {
          console.log(error);
        });
    },
    getApplicantInformationOfUserAccount: function (val) {
      var userAccount = val;
      var _this = this;
      axios
        .post(
          KStarForm.bpmBaseUrl + "/Speech/SpeechIndex/SearchUser?badge=" + userAccount
        )
        .then(function (res) {
          var data = res.data.data;
          var userInfo = eval(data);
          KStarForm.vmFormData.vmFormContent.ApplicantBadge = userInfo[0].Badge; // 工号
          KStarForm.vmFormData.vmFormContent.ApplicantAccount = userInfo[0].UserAccount; // 工号
          KStarForm.vmFormData.vmFormContent.Applicant = userInfo[0].UserName; // 申请人
          KStarForm.vmFormData.vmFormContent.Floor = userInfo[0].userfloor; // 楼号
          KStarForm.vmFormData.vmFormContent.Room = userInfo[0].userroom; // 房间号
          KStarForm.vmFormData.vmFormContent.GroupLeader = userInfo[0].groupleader; // 直属领导
          KStarForm.vmFormData.vmFormContent.GroupLeaderBadge =
            userInfo[0].groupleaderBadge; // 直属领导Badge
          KStarForm.vmFormData.vmFormContent.Jobcname = userInfo[0].Position; // 职称
          KStarForm.vmFormData.vmFormContent.Site = userInfo[0].compid; // 公司

          if (userInfo[0].Costcentercode != "" && userInfo[0].Costcentercode != null) {
            KStarForm.vmFormData.vmFormContent.CostCenter = userInfo[0].Costcentercode; // 成本中心
          }
          if (userInfo[0].DeptName != "" && userInfo[0].DeptName != null) {
            //KStarForm.vmFormData.vmFormContent.Depcname = userInfo[0].DeptName// 部门
            KStarForm.vmFormData.vmFormContent.Depcname = userInfo[0].DeptName; // 部门
          }

          if (
            userInfo[0].Costcentercode == "" ||
            userInfo[0].Costcentercode == null ||
            userInfo[0].DeptName == "" ||
            userInfo[0].DeptName == null
          ) {
            //成本中心
            axios
              .post(
                "/AppicationForPurchase/Common/GetBUCode?badge=" +
                  userInfo[0].Badge +
                  "&DepName=" +
                  userInfo[0].DeptName +
                  ""
              )
              .then(function (res) {
                var costCenterInfo = eval(res.data.data);
                if (costCenterInfo.length > 0) {
                  var compid = userInfo[0].compid;
                  if (compid) {
                    axios
                      .post(
                        "/AppicationForPurchase/Common/GetCodeToCName?cName=" +
                          encodeURIComponent(compid)
                      )
                      .then(function (res) {
                        var array = eval(res.data.data);
                        if (array.length > 0) {
                          if (
                            userInfo[0].Costcentercode == "" ||
                            userInfo[0].Costcentercode == null
                          ) {
                            KStarForm.vmFormData.vmFormContent.CostCenter =
                              array[0].Code + costCenterInfo[0].SAPCode; // 成本中心
                          }
                        } else {
                          if (
                            userInfo[0].Costcentercode == "" ||
                            userInfo[0].Costcentercode == null
                          ) {
                            KStarForm.vmFormData.vmFormContent.CostCenter =
                              costCenterInfo[0].SAPCode; // 成本中心
                          }
                        }
                      })
                      .catch(function (error) {
                        console.log(error);
                      });
                  } else {
                    if (
                      userInfo[0].Costcentercode == "" ||
                      userInfo[0].Costcentercode == null
                    ) {
                      KStarForm.vmFormData.vmFormContent.CostCenter =
                        costCenterInfo[0].SAPCode; // 成本中心
                    }
                  }
                  if (userInfo[0].DeptName == "" || userInfo[0].DeptName == null) {
                    KStarForm.vmFormData.vmFormContent.Depcname =
                      costCenterInfo[0].DepName; // 部门
                  }
                } else {
                  if (
                    userInfo[0].Costcentercode == "" ||
                    userInfo[0].Costcentercode == null
                  ) {
                    KStarForm.vmFormData.vmFormContent.CostCenter = ""; // 成本中心
                    if (KStarForm.vmFormData.vmUserLanguages == "en") {
                      var costCenterTip =
                        "The cost center is empty, please maintain it in the background";
                    } else {
                      var costCenterTip = "成本中心为空，请在后台维护";
                    }
                    _this.$message({
                      showClose: true,
                      message: costCenterTip,
                      type: "error",
                    });
                  }
                  if (userInfo[0].DeptName == "" || userInfo[0].DeptName == null) {
                    KStarForm.vmFormData.vmFormContent.Depcname = ""; // 部门
                    if (KStarForm.vmFormData.vmUserLanguages == "en") {
                      var DeptNameTip =
                        "The department is empty, please maintain it in the background";
                    } else {
                      var DeptNameTip = "部门为空，请在后台维护";
                    }
                    _this.$message({
                      showClose: true,
                      message: DeptNameTip,
                      type: "error",
                    });
                  }
                }
              })
              .catch(function (error) {
                console.log(error);
              });
          }
        })
        .catch(function (err) {
          throw new Error(err);
        });
    },
    isAgentChange: function () {
      var _this = this;
      if (
        KStarForm.vmFormData.vmFormType == "Application" ||
        KStarForm.vmFormData.vmFormType == "Draft" ||
        KStarForm.vmFormData.vmFormType == "ReApproval"
      ) {
        if (KStarForm.vmFormData.vmFormContent.ISAgent == "2") {
          var userBadge = KStarForm.vmFormData.vmFormInstance.Badge;
          _this.getApplicantInformationOfBadge(userBadge);
        }
      }

      this.isAgentDisable =
        KStarForm.vmFormData.vmFormContent.ISAgent == "1" ? false : true;
    },
    //打开工号
    SelectBadge: function () {
      //this.sort = val
      this.showdialog("UserBadge", false);
    },
    //打开弹窗
    showdialog: function (val, multiple) {
      this.parmdialog.clicktype = val;
      switch (val) {
        case "UserBadge":
          this.parmdialog.type = "User";
          this.parmdialog.ctype = "UserPick";
          this.parmdialog.title = "请选择账号";
          break;
      }
      this.parmdialog.dialogvisible = true;
      this.parmdialog.multiplelimit = multiple;
      return false;
    },
    //关闭弹窗
    closedialog: function () {
      this.parmdialog.dialogvisible = false;
    },
    //人员选择后确定
    userpickCallBack: function (val, type) {
      var _this = this;
      var userAccount = val[0].Value;
      _this.getApplicantInformationOfUserAccount(userAccount);
    },
    /*----------申请设备信息----------*/
    isShowReportSPASoftwareList: function (val) {
      var _this = this;
      if (KStarForm.vmFormData.vmFormContent.SoftwareType) {
        _this.SoftwareTypeSearchInput = KStarForm.vmFormData.vmFormContent.SoftwareType;
      }
      _this.dialogAssetNumberFlag = val;
      _this.getReportSPASoftwareList();
    },
    //获取软件清单List
    getReportSPASoftwareList: function () {
      var _this = this;
      var softwareType = _this.SoftwareTypeSearchInput;
      var softwareName = _this.SoftwareNameSearchInput;
      var site = KStarForm.vmFormData.vmFormContent.Site;
      var key = "";
      if (softwareType) {
        key += " And SoftwareType=N'" + softwareType + "'";
      }
      if (softwareName) {
        key += " And SoftwareName  LIKE N'*" + softwareName + "*'";
      }
      key += " And Site in (N'" + site + "',N'公共')";
      axios
        .post(
          KStarForm.bpmBaseUrl +
            "/SPASoftwareListReport/GetReportSPASoftwareList?key=" +
            encodeURIComponent(key)
        )
        .then(function (res) {
          if (res.data.code == 200) {
            var objArray = eval(res.data.data);
            for (var i = 0; i < objArray.length; i++) {
              objArray[i].SoftwareType = _this.dropDownNameOfCode(
                _this.softwareTypeArr,
                objArray[i].SoftwareType
              );
            }
            _this.currentPage = 1;
            _this.reportSoftwareLists = objArray;
            _this.currentreportSoftwareList = [];
            if (objArray.length > 0) {
              _this.currentreportSoftwareList = _this.reportSoftwareLists.slice(
                0,
                _this.dialogPageSize
              );
            }
          }
        });
    },
    //通过软件名称获取软件版本
    softwareDistinctVersion: function (val) {
      var softwareType = KStarForm.vmFormData.vmFormContent.SoftwareType;
      var site = KStarForm.vmFormData.vmFormContent.Site;
      var key = "";
      key += " And SoftwareType=N'" + softwareType + "'";
      key += " And SoftwareName=N'" + val + "'";
      key += " And Site in (N'" + site + "',N'公共')";
      axios
        .get(
          KStarForm.bpmBaseUrl +
            "/SPASoftwareListReport/GetSoftwareVersionOfSoftwareName?key=" +
            encodeURIComponent(key)
        )
        .then(function (res) {
          if (res.data.code == 200) {
            KStarForm.vmFormData.vmFormContent.softwareVersionArr = eval(res.data.data);
          }
        });
    },
    //通过软件名称，软件版本获取获取软件清单数据
    softwareVersionMatch: function () {
      var _this = this;
      var softwareType = KStarForm.vmFormData.vmFormContent.SoftwareType;
      var softwareName = KStarForm.vmFormData.vmFormContent.SoftwareName;
      var softwareVersion = KStarForm.vmFormData.vmFormContent.SoftwareVersion;
      var charge = KStarForm.vmFormData.vmFormContent.Charge;
      var deptName = KStarForm.vmFormData.vmFormContent.Depcname;
      var site = KStarForm.vmFormData.vmFormContent.Site;
      var key = "";
      key += " And SoftwareType=N'" + softwareType + "'";
      key += " And SoftwareName=N'" + softwareName + "'";
      key += " And SoftwareVersion=N'" + softwareVersion + "'";
      //key += " And Depcname in (N'" + deptName + "',N'公共')";
      key += " And Site in (N'" + site + "',N'公共')";
      axios
        .post(
          KStarForm.bpmBaseUrl +
            "/SPASoftwareListReport/GetReportSPASoftwareList?key=" +
            encodeURIComponent(key)
        )
        .then(function (res) {
          if (res.data.code == 200) {
            var objArray = eval(res.data.data);
            if (objArray.length > 0) {
              if (objArray[0].AttachmentFileId) {
                var obj = {};
                obj.NewFileName = objArray[0].LicenseAnnex;
                obj.FileId = objArray[0].AttachmentFileId;
                obj.DownloadUrl = objArray[0].AttachmentDownloadUrl;
                obj.UploadedDate = objArray[0].AttachmentUploadedDate;
                obj.Uploader = objArray[0].AttachmentUploader;
                if (KStarForm.vmFormData.vmFormContent.scoopel.length >= 1) {
                  KStarForm.vmFormData.vmFormContent.scoopel.splice(0, 1, obj);
                } else {
                  KStarForm.vmFormData.vmFormContent.scoopel.push(obj);
                }
              }
              KStarForm.vmFormData.vmFormContent.LicenseKey = objArray[0].LicenseKey; //许可证
              KStarForm.vmFormData.vmFormContent.License = objArray[0].License; //许可证号
              KStarForm.vmFormData.vmFormContent.LicenseAnnex = objArray[0].LicenseAnnex; //许可证附件
              KStarForm.vmFormData.vmFormContent.AttachmentFileId =
                objArray[0].AttachmentFileId; //附件ID
              KStarForm.vmFormData.vmFormContent.AttachmentDownloadUrl =
                objArray[0].AttachmentDownloadUrl; //附件URL
              KStarForm.vmFormData.vmFormContent.AttachmentUploadedDate =
                objArray[0].AttachmentUploadedDate; //附件上传时间
              KStarForm.vmFormData.vmFormContent.AttachmentUploader =
                objArray[0].AttachmentUploader; //附件上传者
              KStarForm.vmFormData.vmFormContent.DetailSPASoftwareListID = objArray[0].Id; //清单报表ID
              KStarForm.vmFormData.vmFormContent.InstallationPackage =
                objArray[0].InstallationPackage; // 是否有安装包
              KStarForm.vmFormData.vmFormContent.OriginalSoftwareManufacturer =
                objArray[0].OriginalSoftwareManufacturer; // 软件原厂商
              KStarForm.vmFormData.vmFormContent.Charge = objArray[0].Charge; // 是否收费SoftwareType
              KStarForm.vmFormData.vmFormContent.Availability = objArray[0].Availability; //软件有效性
              if (
                KStarForm.vmFormData.vmFormType == "Application" ||
                KStarForm.vmFormData.vmFormType == "Draft" ||
                KStarForm.vmFormData.vmFormType == "ReApproval"
              ) {
                if (softwareType == "2" || (softwareType == "3" && charge == "1")) {
                  //判断License配额是否存足   [FreeQuotas] + [RemainingAvailableQuotas]
                  if (
                    parseInt(objArray[0].RemainingAvailableQuotas) +
                      parseInt(objArray[0].FreeQuotas) <=
                    0
                  ) {
                    debugger;
                    KStarForm.vmFormData.vmFormContent.IsEnoughLicence = false;
                    _this.$message({
                      showClose: true,
                      message: _this.$tf("event.AttentionTip"),
                      type: "error",
                    });
                  } else {
                    KStarForm.vmFormData.vmFormContent.IsEnoughLicence = true;
                  }
                }
              }
            }
          }
        });
    },
    //软件版本改变事件
    softwareVersionChange: function () {
      var _this = this;
      if (
        KStarForm.vmFormData.vmFormType == "Application" ||
        KStarForm.vmFormData.vmFormType == "Draft" ||
        KStarForm.vmFormData.vmFormType == "ReApproval"
      ) {
        if (KStarForm.vmFormData.vmUserLanguages == "en") {
          var SoftwareNameTip = "The software name cannot be empty";
          var SoftwareVersionTip = "The software version cannot be empty";
          var SoftwareNameOfOtherTip = "The software name cannot be other";
        } else {
          var SoftwareNameTip = "软件名称不能为空";
          var SoftwareVersionTip = "软件版本不能为空";
          var SoftwareNameOfOtherTip = "软件名称不能为其他";
        }
        if (!KStarForm.vmFormData.vmFormContent.SoftwareName) {
          _this.$message({ showClose: true, message: SoftwareNameTip, type: "error" });
          return false;
        } else {
          if (
            KStarForm.vmFormData.vmFormContent.SoftwareName == "其他" &&
            KStarForm.vmFormData.vmFormContent.SoftwareType == "3"
          ) {
            _this.$message({
              showClose: true,
              message: SoftwareNameOfOtherTip,
              type: "error",
            });
            return false;
          }
        }
        if (!KStarForm.vmFormData.vmFormContent.SoftwareVersion) {
          _this.$message({ showClose: true, message: SoftwareVersionTip, type: "error" });
          return false;
        }
        var obj = {};
        obj.SoftwareType = KStarForm.vmFormData.vmFormContent.SoftwareType;
        obj.SoftwareName = KStarForm.vmFormData.vmFormContent.SoftwareName;
        obj.SoftwareVersion = KStarForm.vmFormData.vmFormContent.SoftwareVersion;
        var flag;
        $.ajax({
          type: "post",
          async: false,
          url:
            KStarForm.bpmBaseUrl +
            "/AppicationForPurchase/SPASoftwareListReport/IsHaveQuotas",
          data: { model: obj },
          dataType: "text",
          success: function (data) {
            flag = data;
          },
        });
        if (flag == "False") {
          _this.$message({
            showClose: true,
            message: _this.$tf("event.AttentionTip"),
            type: "error",
          });
        }
      }
    },
    //判断预算号是否为18位
    validateNumOfBudgetNumber: function (val) {
      if (KStarForm.vmFormData.vmUserLanguages == "en") {
        var BudgetNumberTip = "Please fill in the Budget Number correctly";
      } else {
        var BudgetNumberTip = "请填写正确的预算号";
      }
      var _this = this;
      if (!/^\d{18}$/.test(val)) {
        _this.$message({
          showClose: true,
          message: BudgetNumberTip,
          type: "error",
        });
      }
    },
    //软件类型Change事件
    softwareTypeChange: function (val) {
      var _this = this;
      KStarForm.vmFormData.vmFormContent.IsEnoughLicence == false;
      KStarForm.vmFormData.vmFormContent.scoopel = [];
      KStarForm.vmFormData.vmFormContent.LicenseKey = ""; //许可证
      KStarForm.vmFormData.vmFormContent.License = ""; //许可证号
      KStarForm.vmFormData.vmFormContent.LicenseAnnex = ""; //许可证附件
      KStarForm.vmFormData.vmFormContent.AttachmentFileId = ""; //附件ID
      KStarForm.vmFormData.vmFormContent.AttachmentDownloadUrl = ""; //附件URL
      KStarForm.vmFormData.vmFormContent.AttachmentUploadedDate = ""; //附件上传时间
      KStarForm.vmFormData.vmFormContent.AttachmentUploader = ""; //附件上传者
      KStarForm.vmFormData.vmFormContent.DetailSPASoftwareListID = ""; //清单报表ID
      KStarForm.vmFormData.vmFormContent.InstallationPackage = ""; // 是否有安装包
      KStarForm.vmFormData.vmFormContent.OriginalSoftwareManufacturer = ""; // 软件原厂商
      KStarForm.vmFormData.vmFormContent.Charge = ""; // 是否收费SoftwareType
      KStarForm.vmFormData.vmFormContent.Availability = ""; //软件有效性
      KStarForm.vmFormData.vmFormContent.SoftwareName = ""; //软件名称
      KStarForm.vmFormData.vmFormContent.SoftwareVersion = ""; //软件版本
      KStarForm.vmFormData.vmFormContent.softwareVersionArr = "";
      _this.currentreportSoftwareList = [];
      _this.SoftwareTypeSearchInput = val;
      if (val == 3) {
        KStarForm.vmFormData.vmFormContent.SoftwareName = "其他"; //软件名称
        KStarForm.vmFormData.vmFormContent.isSoftwareVersionHidden = true; //软件版本输入框
      } else {
        KStarForm.vmFormData.vmFormContent.isSoftwareVersionHidden = false; //软件版本输入框
      }
    },
    // 弹框搜索按钮
    reportSPASoftwareListSearchBtn: function () {
      var _this = this;
      _this.getReportSPASoftwareList();
    },
    // 弹框_软件名称分页页码切换
    reportSPASoftwareListSizeChange: function (val) {
      this.currentPage = val;
      this.currentreportSoftwareList = this.reportSoftwareLists.slice(
        (val - 1) * this.dialogPageSize,
        val * this.dialogPageSize
      );
    },
    // 弹框_软件名称暂存选择软件数据
    checkedTemporary: function (val) {
      this.temporaryChecked = val;
    },
    // 弹框_软件名称确定软件数据
    checkedReportSPASoftwareListEvent: function () {
      var _this = this;
      if (
        !_this.temporaryChecked ||
        !_this.temporaryChecked.hasOwnProperty("SoftwareName")
      ) {
        _this.$message.error($tf("Form.selectReportSPASoftwareList"));
        return false;
      }
      _this.dialogAssetNumberFlag = false;
      _this.temporaryChecked.SoftwareType = _this.dropDownCodeOfName(
        _this.softwareTypeArr,
        _this.temporaryChecked.SoftwareType
      );
      KStarForm.vmFormData.vmFormContent.SoftwareType =
        _this.temporaryChecked.SoftwareType; //软件类型
      KStarForm.vmFormData.vmFormContent.SoftwareName =
        _this.temporaryChecked.SoftwareName; //软件名称
      _this.softwareDistinctVersion(_this.temporaryChecked.SoftwareName); //获取软件版本下拉
      KStarForm.vmFormData.vmFormContent.isSoftwareVersionHidden = false; //软件版本输入框

      KStarForm.vmFormData.vmFormContent.scoopel = [];
      KStarForm.vmFormData.vmFormContent.SoftwareVersion = ""; //软件版本
      KStarForm.vmFormData.vmFormContent.LicenseKey = ""; //许可证
      KStarForm.vmFormData.vmFormContent.License = ""; //许可证号
      KStarForm.vmFormData.vmFormContent.LicenseAnnex = ""; //许可证附件
      KStarForm.vmFormData.vmFormContent.AttachmentFileId = ""; //附件ID
      KStarForm.vmFormData.vmFormContent.AttachmentDownloadUrl = ""; //附件URL
      KStarForm.vmFormData.vmFormContent.AttachmentUploadedDate = ""; //附件上传时间
      KStarForm.vmFormData.vmFormContent.AttachmentUploader = ""; //附件上传者
      KStarForm.vmFormData.vmFormContent.DetailSPASoftwareListID = ""; //清单报表ID
      KStarForm.vmFormData.vmFormContent.InstallationPackage = ""; // 是否有安装包
      KStarForm.vmFormData.vmFormContent.OriginalSoftwareManufacturer = ""; // 软件原厂商
      KStarForm.vmFormData.vmFormContent.Charge = ""; // 是否收费SoftwareType
      KStarForm.vmFormData.vmFormContent.Availability = ""; //软件有效性
    },
    /*----------部门采购信息----------*/
    //证件号附件
    useStampInfosUpload: function () {
      this.$refs.stempUpload.click();
    },
    beforeupload: function (file) {
      var _this = this;
      _this.loading = true;
      debugger;
      var fd = new FormData();
      var procssGuid = "SoftwarePurchaseApplication_Index";
      fd.append("file", file);

      axios
        .post("/purchase/attachment/SaveAttachments?AttachmentGuid=" + procssGuid, fd, {
          headers: {
            "Content-Type": "multipart/form-data",
          },
        })
        .then(function (res) {
          KStarForm.vmFormData.vmFormContent.LicenseAnnex = res.data.data.FileName; //许可证附件
          KStarForm.vmFormData.vmFormContent.AttachmentFileId = res.data.data.FileGuid; //附件ID
          KStarForm.vmFormData.vmFormContent.AttachmentDownloadUrl =
            res.data.data.FileURL; //附件URL
          KStarForm.vmFormData.vmFormContent.AttachmentUploadedDate =
            res.data.data.UploadDate; //附件上传时间
          KStarForm.vmFormData.vmFormContent.AttachmentUploader =
            res.data.data.OperatorAd; //附件上传者
          var obj = {};
          obj.NewFileName = res.data.data.FileName;
          obj.FileId = res.data.data.FileGuid;
          obj.DownloadUrl = res.data.data.FileURL;
          obj.UploadedDate = res.data.data.UploadDate;
          obj.Uploader = res.data.data.OperatorAd;
          if (obj.Uploader != null) {
            var arr = []; //记录已上传附件名称
            for (var i = 0; i < KStarForm.vmFormData.vmFormContent.scoopel.length; i++) {
              arr.push(KStarForm.vmFormData.vmFormContent.scoopel[i].NewFileName);
            }
            if (arr.indexOf(obj.NewFileName) != -1) {
              if (KStarForm.vmFormData.vmUserLanguages == "en") {
                _this.$message.error(
                  "This file has been uploaded and do not upload attachments with the same document name repeatedly"
                );
              } else {
                _this.$message.error("此文件已经上传，请勿重复上传同样文档名的附件");
              }
            } else {
              KStarForm.vmFormData.vmFormContent.scoopel.push(obj);
              if (KStarForm.vmFormData.vmUserLanguages == "en") {
                _this.$message({
                  message: "File Upload Successfully",
                  type: "success",
                });
              } else {
                _this.$message({
                  message: "文件上传成功",
                  type: "success",
                });
              }
            }
          } else {
            if (KStarForm.vmFormData.vmUserLanguages == "en") {
              _this.$message.error("File Upload Failed");
            } else {
              _this.$message.error("文件上传失败");
            }
          }
          _this.loading = false;
        });
    },
    seefile: function (val) {
      var road = val.row.DownloadUrl;
      var filename = road.split("\\")[4];
      if (road.indexOf("KStarPublish") != -1) {
        var filed = road.split("KStar.Form.Web");
        console.log(filed[0], filed[1]);
        var href = window.location.origin;
        road = href + filed[1];
      }

      if (this.isiphone == false) {
        //road = 'http://140.206.58.42:9088/ImportExcelFile/' + filename
        road = "../../ImportExcelFile/" + filename;
      }
      window.open(road);
    },
    deleteRowFile: function (index, file, val, rows) {
      KStarForm.vmFormData.vmFormContent.scoopel.splice(index, 1);
    },
    /*----------软件清单记录报表----------*/
    //license配额焦点事件
    licenseQuotasBlur: function (val) {
      var index = val.$index;
      KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[
        index
      ].RemainingAvailableQuotas = val.row.LicenseQuotas;
    },
    //软件清单记录新增
    detailSPASoftwareListsAdd: function () {
      this.AddType();
    },
    //删除软件清单数据
    deleteDetailSPASoftwareListsRow: function (index, rows) {
      var _this = this;
      _this
        .$confirm(_this.$tf("dialog.delete"), _this.$tf("dialog.reminder"), {
          confirmButtonText: _this.$tf("dialog.confirm"),
          cancelButtonText: _this.$tf("dialog.cancel1"),
          type: "warning",
        })
        .then(function () {
          rows.splice(index, 1);
          _this.$message({
            type: "success",
            message: _this.$tf("dialog.deleteed"),
          });
        })
        .catch(function () {
          _this.$message({
            type: "info",
            message: _this.$tf("dialog.nodelete"),
          });
        });
    },
    //许可证附件上传
    licenseAnnexUpload: function (val) {
      //this.upFile = val.$index
      if (val.row.AttachmentDownloadUrl != "" && val.row.AttachmentDownloadUrl != null) {
        this.openssss(val);
      } else {
        this.$refs.stempUploadofLicenseAnnex.click();
      }
    },
    beforeuploadofLicenseAnnex: function (file) {
      var _this = this;
      var fd = new FormData();
      fd.append("file", file);
      var procssGuid = "ReportSPASoftwareList_Index_Detail";
      axios
        .post("/purchase/attachment/SaveAttachments?AttachmentGuid=" + procssGuid, fd, {
          headers: {
            "Content-Type": "multipart/form-data",
          },
        })
        .then(function (res) {
          if (res.data.data.OperatorAd != null) {
            if (KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists.length > 0) {
              KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0].LicenseAnnex =
                res.data.data.FileName;
              KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0].AttachmentFileId =
                res.data.data.FileGuid;
              KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0].AttachmentDownloadUrl =
                res.data.data.FileURL;
              KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0].AttachmentUploadedDate =
                res.data.data.UploadDate;
              KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0].AttachmentUploader =
                res.data.data.OperatorAd;
            } else {
              _this.file_Temp.LicenseAnnex = res.data.data.FileName;
              _this.file_Temp.AttachmentFileId = res.data.data.FileGuid;
              _this.file_Temp.AttachmentDownloadUrl = res.data.data.FileURL;
              _this.file_Temp.AttachmentUploadedDate = res.data.data.UploadDate;
              _this.file_Temp.AttachmentUploader = res.data.data.OperatorAd;
            }
            if (KStarForm.vmFormData.vmUserLanguages == "en") {
              _this.$message({
                message: "File Upload Successfully",
                type: "success",
              });
            } else {
              _this.$message({
                message: "文件上传成功",
                type: "success",
              });
            }
          } else {
            if (KStarForm.vmFormData.vmUserLanguages == "en") {
              _this.$message.error("File Upload Failed");
            } else {
              _this.$message.error("文件上传失败");
            }
          }
        });
    },
    //查看附件
    seeLicenseAnnexfile: function (val) {
      var _this = this;
      var road = val.row.AttachmentDownloadUrl;
      if (road == "" || road == null) {
        _this.$message({
          type: "info",
          message: _this.$tf("Form.dialog.file"),
        });
        return false;
      }
      window.open(val.row.AttachmentDownloadUrl);
    },
    openssss: function (val) {
      var _this = this;
      this.$confirm(_this.$tf("Form.oldupload"), _this.$tf("dialog.reminder"), {
        confirmButtonText: _this.$tf("dialog.confirm"),
        cancelButtonText: _this.$tf("dialog.cancel1"),
        type: "warning",
      })
        .then(function () {
          //val.row.AttachmentDownloadUrl = ''
          this.$refs.stempUploadofLicenseAnnex.click();
        })
        .catch(function () {
          _this.$message({
            type: "info",
            message: _this.$tf("Form.upload"),
          });
        });
    },
    //弹框_软件清单记录报表_取消
    cancel: function () {
      this.editT = false;
    },
    //弹框_软件清单记录报表_确认
    changeIn: function () {
      var _this = this;
      console.log(_this.form);
      if (_this.langu == "en") {
        var SiteTip = "The company cannot be empty";
        var DepcnameTip = "The department cannot be empty";
        var SoftwareTypeTip = "The software type cannot be empty";
        var SoftwareNameTip = "The software name cannot be empty";
        var SoftwareVersionTip = "The software version cannot be empty";
        var InstallationPackageTip =
          "Whether there is an installation package cannot be empty";
        var ChargeTip = "Whether the charge cannot be empty";
        var LicenseQuotasTip = "The License quota cannot be empty";
        var PurchaseTimeTip = "The software purchase time cannot be empty";
        var ExpireDateTip = "The expiration time cannot be empty";
        var AvailabilityTip = "Software validity cannot be empty";
        var DisableTip = "Whether to disable";
      } else {
        var SiteTip = "公司不能为空";
        var DepcnameTip = "部门不能为空";
        var SoftwareTypeTip = "软件类型不能为空";
        var SoftwareNameTip = "软件名称不能为空";
        var SoftwareVersionTip = "软件版本不能为空";
        var InstallationPackageTip = "是否有安装包不能为空";
        var ChargeTip = "是否收费不能为空";
        var LicenseQuotasTip = "License配额不能为空";
        var PurchaseTimeTip = "软件采购时间不能为空";
        var ExpireDateTip = "到期时间不能为空";
        var AvailabilityTip = "软件有效性不能为空";
        var DisableTip = "是否禁用";
      }
      if (!_this.form.Site) {
        _this.$message({
          showClose: true,
          message: SiteTip,
          type: "error",
        });
      }
      if (!_this.form.Depcname) {
        _this.$message({
          showClose: true,
          message: DepcnameTip,
          type: "error",
        });
      }
      if (!_this.form.SoftwareType) {
        _this.$message({
          showClose: true,
          message: SoftwareTypeTip,
          type: "error",
        });
      }
      if (!_this.form.SoftwareName) {
        _this.$message({
          showClose: true,
          message: SoftwareNameTip,
          type: "error",
        });
        return false;
      }
      if (!_this.form.SoftwareVersion) {
        _this.$message({
          showClose: true,
          message: SoftwareVersionTip,
          type: "error",
        });
        return false;
      }
      if (!_this.form.InstallationPackage) {
        _this.$message({
          showClose: true,
          message: InstallationPackageTip,
          type: "error",
        });
        return false;
      }
      if (!_this.form.Charge) {
        _this.$message({
          showClose: true,
          message: ChargeTip,
          type: "error",
        });
        return false;
      }
      if (!_this.form.LicenseQuotas) {
        _this.$message({ showClose: true, message: LicenseQuotasTip, type: "error" });
        return false;
      }
      if (!_this.form.PurchaseTime) {
        _this.$message({ showClose: true, message: PurchaseTimeTip, type: "error" });
        return false;
      }
      if (!_this.form.ExpireDate) {
        _this.$message({ showClose: true, message: ExpireDateTip, type: "error" });
        return false;
      }
      if (!_this.form.Availability) {
        _this.$message({ showClose: true, message: AvailabilityTip, type: "error" });
        return false;
      }
      if (!_this.form.Disable) {
        _this.$message({ showClose: true, message: DisableTip, type: "error" });
        return false;
      }
      var obj = _this.form;
      var file_Temp = _this.file_Temp;
      KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists.push({
        Site: obj.Site,
        Depcname: obj.Depcname,
        SoftwareType: obj.SoftwareType,
        SoftwareName: obj.SoftwareName,
        SoftwareVersion: obj.SoftwareVersion,
        OriginalSoftwareManufacturer: obj.OriginalSoftwareManufacturer,
        InstallationPackage: obj.InstallationPackage,
        Charge: obj.Charge,
        LicenseQuotas: obj.LicenseQuotas,
        FreeQuotas: obj.FreeQuotas,
        UsedQuotas: obj.UsedQuotas,
        RemainingAvailableQuotas: obj.RemainingAvailableQuotas,
        PurchaseTime: obj.PurchaseTime,
        ExpireDate: obj.ExpireDate,
        Availability: obj.Availability,
        LicenseKey: obj.LicenseKey,
        License: obj.License,
        LicenseAnnex: file_Temp.LicenseAnnex,
        AttachmentFileId: file_Temp.AttachmentFileId,
        AttachmentDownloadUrl: file_Temp.AttachmentDownloadUrl,
        AttachmentUploadedDate: file_Temp.AttachmentUploadedDate,
        AttachmentUploader: file_Temp.AttachmentUploader,
        Comments: obj.Comments,
      });
      _this.editT = false;
    },
    //弹框_软件清单记录报表_是否收费Change事件
    chargeChange: function (val) {
      var _this = this;
      if (val == 1) {
        _this.form.Site = "";
        _this.form.Depcname = "";
      } else if (val == 2) {
        _this.form.Site = "公共";
        _this.form.Depcname = "公共";
      }
      if (_this.form.SoftwareType == "3" && val == "1") {
        var date = new Date();
        _this.form.PurchaseTime = new Date();
        _this.form.ExpireDate = moment(date.setFullYear(date.getFullYear() + 10)).format(
          "YYYY-MM-DD"
        );
      } else {
        var date = new Date();
        _this.form.PurchaseTime = new Date();
        _this.form.ExpireDate = moment(date.setFullYear(date.getFullYear() + 10)).format(
          "YYYY-MM-DD"
        );
      }
    },
    //弹框_软件清单记录报表_编辑
    handleClick: function (val) {
      var _this = this;
      val.SoftwareType = _this.dropDownCodeOfName(
        _this.softwareTypeArr,
        val.SoftwareType
      );
      val.InstallationPackage = _this.dropDownCodeOfName(
        _this.whetherArr,
        val.InstallationPackage
      );
      val.Charge = _this.dropDownCodeOfName(_this.whetherArr, val.Charge);
      val.Availability = _this.dropDownCodeOfName(
        _this.availabilityArr,
        val.Availability
      );
      val.Disable = _this.dropDownCodeOfName(_this.whetherArr, val.Disable);
      this.scope_Edit = val;
      this.DioTitle = "编辑信息";
      this.form = JSON.parse(JSON.stringify(val));
      this.form1 = JSON.parse(JSON.stringify(val));
      this.editT = true;
      this.isEd = true;
    },
    //弹框_软件清单记录报表_添加
    AddType: function () {
      (this.form.Site = ""),
        (this.form.Depcname = ""),
        (this.form.SoftwareType = ""),
        (this.form.SoftwareName = ""),
        (this.form.SoftwareVersion = ""),
        (this.form.OriginalSoftwareManufacturer = ""),
        (this.form.InstallationPackage = ""),
        (this.form.Charge = ""),
        (this.form.LicenseQuotas = ""),
        (this.form.FreeQuotas = "0"),
        (this.form.UsedQuotas = "0"),
        (this.form.RemainingAvailableQuotas = ""),
        (this.form.PurchaseTime = ""),
        (this.form.ExpireDate = ""),
        (this.form.Availability = ""),
        (this.form.LicenseKey = ""),
        (this.form.License = ""),
        (this.form.LicenseAnnex = ""),
        (this.form.AttachmentFileId = ""),
        (this.form.AttachmentDownloadUrl = ""),
        (this.form.AttachmentUploadedDate = ""),
        (this.form.AttachmentUploader = ""),
        (this.form.Disable = ""),
        (this.form.Comments = ""),
        (this.form.ID = ""),
        (this.form.Availability = "1"),
        (this.form.Disable = "2"),
        (this.DioTitle = "新增信息");
      this.editT = true;
      this.isEd = false;
    },
    //弹框_软件清单记录报表_采购时间Change事件
    purchaseTimeChange: function (val) {
      var _this = this;
      var date = new Date();
      var expireDate = _this.form.ExpireDate;
      if (!expireDate) {
        if (val > date) {
          _this.$message({
            showClose: true,
            message: _this.$tf("event.purchaseTimeChangeTip"),
            type: "error",
          });
          _this.form.PurchaseTime = "";
          return false;
        }
      } else {
        if (val > expireDate) {
          _this.$message({
            showClose: true,
            message: _this.$tf("event.purchaseTimeChange1Tip"),
            type: "error",
          });
          _this.form.PurchaseTime = "";
          return false;
        }
      }
    },
    //弹框_软件清单记录报表_到期时间Change事件
    expireDateChange: function (val) {
      var _this = this;
      var date = new Date();
      var purchaseTime = _this.form.PurchaseTime;
      if (val < purchaseTime) {
        _this.$message({
          showClose: true,
          message: _this.$tf("event.expireDateChangeTip"),
          type: "error",
        });
        _this.form.ExpireDate = "";
        return false;
      }
      if (val > date) {
        _this.form.Availability = "1";
      } else {
        _this.form.Availability = "2";
      }
    },
    //弹框_软件清单记录报表_公司Change事件
    siteChange: function (val) {
      var _this = this;
      _this.form.Depcname = "";
    },
    //弹框_软件清单记录报表_软件类型Change事件
    softwareTypeChangeOfBox: function (val) {
      var _this = this;
      if (val == "1") {
        _this.form.Site = "公共";
        _this.form.Depcname = "公共";
        _this.form.Charge = "2";
      } else if (val == "2") {
        if (_this.form.Site == "公共") {
          _this.form.Site = "";
        }
        if (_this.form.Depcname == "公共") {
          _this.form.Depcname = "";
        }
        _this.form.Charge = "1";
      } else if (val == "3") {
        if (_this.form.Site == "公共") {
          _this.form.Site = "";
        }
        if (_this.form.Depcname == "公共") {
          _this.form.Depcname = "";
        }
        _this.form.Charge = "1";
      }
      if (val == "3" && _this.form.Charge == "1") {
        var date = new Date();
        _this.form.PurchaseTime = new Date();
        _this.form.ExpireDate = moment(date.setFullYear(date.getFullYear() + 10)).format(
          "YYYY-MM-DD"
        );
      } else {
        var date = new Date();
        _this.form.PurchaseTime = new Date();
        _this.form.ExpireDate = moment(date.setFullYear(date.getFullYear() + 10)).format(
          "YYYY-MM-DD"
        );
      }
    },
    //弹框_软件清单记录报表_配额总数量焦点事件
    licenseQuotasBlur: function (val) {
      var _this = this;
      _this.form.RemainingAvailableQuotas = val;
    },
    //弹框_软件清单记录报表_许可证附件上传
    licenseAnnexUploadOfBox: function (val) {
      if (val.AttachmentDownloadUrl != "" && val.AttachmentDownloadUrl != null) {
        this.openssss(val);
      } else {
        this.$refs.stempUploadofLicenseAnnex.click();
      }
    },
    //弹框_软件清单记录报表_查看附件
    seefileOfBox: function (val) {
      var _this = this;
      var road = val.AttachmentDownloadUrl;
      if (road == "" || road == null) {
        _this.$message({
          type: "info",
          message: _this.$tf("dialog.file"),
        });
        return false;
      }
      window.open(road);
    },
    /*----------Common----------*/
    //获取下拉框的值
    dropDownNameOfCode: function (array, code) {
      var _this = this;
      var objArray = array;
      for (var i = 0; i < objArray.length; i++) {
        if (objArray[i].Code == code) {
          return _this.langu == "cn" ? objArray[i].Name : objArray[i].EName;
        }
      }
    },
    //通过Name获取下拉框的Code
    dropDownCodeOfName: function (array, name) {
      var _this = this;
      var objArray = array;
      for (var i = 0; i < objArray.length; i++) {
        var getValue = _this.langu == "cn" ? objArray[i].Name : objArray[i].EName;
        if (getValue == name) {
          return objArray[i].Code;
        }
      }
    },
  },
  setup() {
    let formData = reactive(KStarForm.vmFormData);

    var bpmform = ref(null);
    KStarForm.vmFormData = formData;
    const { proxy, ctx } = getCurrentInstance();

    var FormContentModel = {
        groupCategory: [
          {
            value: 1,
            label: "邮件组",
          },
          {
            value: 2,
            label: "权限组",
          },
          {
            value: 3,
            label: "公司级全员邮件组",
          },
        ],
        //申请类别下拉框数据
        groupTypeOptions: [
          {
            value: 1,
            label: "组创建",
          },
          {
            value: 2,
            label: "权限变更",
          },
          {
            value: 3,
            label: "Owner变更",
          },
          {
            value: 4,
            label: "组删除",
          },
        ],
        //邮件组账号提醒数据
        groupEmailOptions: [
          {
            value: "1",
            label: "wangyichen@wuxibiologics.com",
          },
          {
            value: "2",
            label: "zhangning@wuxibiologics.com",
          },
          {
            value: "3",
            label: "hezhenhang@wuxibiologics.com",
          },
        ],
        groupFrom: {
          groupType: 1,
          groupCategory: 1,
          groupAccount: "",
          groupName: "",
          Owner: "张宁",
        },
    };

    window.FormContentModel = FormContentModel;

    var FormLang = {
      cn: {
            Form: {
                //申请信息
                groupAccount: "组账户",
                groupType: "申请类别",
                groupCategory: "组类别",
                groupName: "组显示名",
                Owner: "Owner",
                Depcnames: "部门",
                groupEmail: "邮件组账号",
                groupIimits: "权限组账号",
                currentOwner: "现Owner",
                pastOwners: "变更后Owner",
                applicationReason: "申请理由",
            }
      },
      en: {
        Form: {
            groupAccount: "组账户",
          groupType: "申请类别",
          groupCategory: "组类别",
          groupName: "组显示名",
          Owner: "Owner",
          Depcnames: "部门",
          groupEmail: "邮件组账号",
          groupIimits: "权限组账号",
          currentOwner: "现Owner",
          pastOwners: "变更后Owner",
          applicationReason: "申请理由",
          Depcnames: "Depcname",
          //提示
        },
      },
    };

    KStarForm.onMergeLangMessages = () => {
      return FormLang;
    };

    // //初始化数据后绑定之前
    // KStarForm.initFormDataAfter = function () {
    //     var _this = this

    //     KStarForm.vmFormData.NextApprover = "k2admin";
    //     KStarForm.vmFormData.NextActivityID = 2;
    //     //标题中英文
    //     if (KStarForm.vmFormData.vmUserLanguages == "en") {
    //         KStarForm.vmFormData.vmFormInstance.ProcessName += "流程";
    //     } else {
    //         KStarForm.vmFormData.vmFormInstance.ProcessName += "流程";
    //     }
    // }

    //初始化数据后绑定之前
    KStarForm.initFormDataAfter = function () {
      var _this = ctx;

      KStarForm.vmFormData.vmFormInstance.FormSubject = "软件使用申请";
      // 初始一个标题，表单验证了标题不能为空.

      //引用赋值回来，方便迁移代码继续操作FormContentModel
      //   FormContentModel = formData.vmFormContent
    };

    // 提交表单前
    KStarForm.onSubmitBefore = function () {
      return submitVerify(KStarForm.VM);
    };
    //提交前必填验证
    KStarForm.onReSubmitBefore = function () {
      return submitVerify(KStarForm.VM);
    };

    function submitVerify(_this) {
      if (KStarForm.vmFormData.vmUserLanguages == "en") {
        var costCenterTip =
          "The cost center is empty, please maintain it in the background";
        var DeptNameTip = "The department is empty, please maintain it in the background";

        var ComputerNameTip = "The computer name cannot be empty";
        var SoftwareTypeTip = "The software type cannot be empty";
        var SoftwareNameTip = "The software name cannot be empty";
        var SoftwareVersionTip = "The software version cannot be empty";
        var InstallationPackageTip =
          "Whether there is an installation package cannot be empty";
        var ChargeTip = "Whether the charge cannot be empty";
        var QuantityTip = "The number of applications cannot be empty";
        var SoftwareNameOfOtherTip = "The software name cannot be other";
        var AttentionTip =
          "The software license that you're applying is insufficient, department head's approval is needed before purchasing. Please submit and wait patiently!";
        var ReasonForApplicationTip = "The reason for application cannot be empty";
        var SubmitTip =
          "Unable to retrieve the personal position information and direct leadership information of the acting applicant. Currently, the application cannot be submitted. Please contact the 400 servicedesk";
      } else {
        var costCenterTip = "成本中心为空，请在后台维护";
        var DeptNameTip = "部门为空，请在后台维护";
        var ComputerNameTip = "计算机名不能为空";
        var SoftwareTypeTip = "软件类型不能为空";
        var SoftwareNameTip = "软件名称不能为空";
        var SoftwareVersionTip = "软件版本不能为空";
        var InstallationPackageTip = "是否有安装包不能为空";
        var ChargeTip = "是否收费不能为空";
        var QuantityTip = "申请数量不能为空";
        var SoftwareNameOfOtherTip = "软件名称不能为其他";
        var AttentionTip =
          "您申请的软件的License配额不足，部门领导审批通过后才能采购，请提交后，耐心等待！";
        var ReasonForApplicationTip = "申请原因不能为空";
        var SubmitTip =
          "无法检索到代理申请人的个人职位信息及直属领导信息，当前无法提交该申请，请联系400服务台";
      }
      if (!KStarForm.vmFormData.vmFormContent.CostCenter) {
        _this.$message({ showClose: true, message: costCenterTip, type: "error" });
        return false;
      }
      if (!KStarForm.vmFormData.vmFormContent.Depcname) {
        _this.$message({ showClose: true, message: DeptNameTip, type: "error" });
        return false;
      }
      if (!KStarForm.vmFormData.vmFormContent.ComputerName) {
        _this.$message({ showClose: true, message: ComputerNameTip, type: "error" });
        return false;
      }
      if (!KStarForm.vmFormData.vmFormContent.SoftwareType) {
        _this.$message({ showClose: true, message: SoftwareTypeTip, type: "error" });
        return false;
      }
      if (!KStarForm.vmFormData.vmFormContent.SoftwareName) {
        _this.$message({ showClose: true, message: SoftwareNameTip, type: "error" });
        return false;
      } else {
        if (
          KStarForm.vmFormData.vmFormContent.SoftwareName == "其他" &&
          KStarForm.vmFormData.vmFormContent.SoftwareType == "3"
        ) {
          _this.$message({
            showClose: true,
            message: SoftwareNameOfOtherTip,
            type: "error",
          });
          return false;
        }
      }
      if (!KStarForm.vmFormData.vmFormContent.SoftwareVersion) {
        _this.$message({ showClose: true, message: SoftwareVersionTip, type: "error" });
        return false;
      }
      if (!KStarForm.vmFormData.vmFormContent.InstallationPackage) {
        _this.$message({
          showClose: true,
          message: InstallationPackageTip,
          type: "error",
        });
        return false;
      }
      if (!KStarForm.vmFormData.vmFormContent.Charge) {
        _this.$message({ showClose: true, message: ChargeTip, type: "error" });
        return false;
      }
      if (!KStarForm.vmFormData.vmFormContent.Quantity) {
        _this.$message({ showClose: true, message: QuantityTip, type: "error" });
        return false;
      }
      if (!KStarForm.vmFormData.vmFormContent.ReasonForApplication) {
        _this.$message({
          showClose: true,
          message: ReasonForApplicationTip,
          type: "error",
        });
        return false;
      }

      var _bpmtoken = window.sessionStorage.getItem(KStarForm.tokenName);
      if (KStarForm.vmFormData.vmFormContent.DetailSPASoftwareListID) {
        var flag;
        $.ajax({
          type: "post",
          async: false,
          headers: { _bpmtoken: _bpmtoken },
          url:
            KStarForm.bpmBaseUrl +
            "/AppicationForPurchase/SPASoftwareListReport/IsHaveRemainingAvailableQuotas",
          data: { id: KStarForm.vmFormData.vmFormContent.DetailSPASoftwareListID },
          dataType: "text",
          success: function (data) {
            flag = data;
          },
        });

        if (
          KStarForm.vmFormData.vmFormContent.SoftwareType == "2" ||
          (KStarForm.vmFormData.vmFormContent.SoftwareType == "3" &&
            KStarForm.vmFormData.vmFormContent.Charge == "1")
        ) {
          if (flag == "False") {
            KStarForm.VM.$message({
              showClose: true,
              message: AttentionTip,
              type: "error",
            });
            KStarForm.vmFormData.vmFormContent.IsEnoughLicence = false;
          } else {
            KStarForm.vmFormData.vmFormContent.IsEnoughLicence = true;
          }
        }
      }

      if (KStarForm.vmFormData.vmFormContent.ISAgent == "1") {
        if (KStarForm.vmFormData.vmFormType != "ReApproval") {
          //代理申请人职级不完整，无法提交申请
          if (
            KStarForm.vmFormData.vmFormContent.GroupLeaderBadge != undefined &&
            KStarForm.vmFormData.vmFormContent.GroupLeaderBadge != null &&
            KStarForm.vmFormData.vmFormContent.GroupLeaderBadge != ""
          ) {
            var arr;
            var userAccount = KStarForm.vmFormData.vmFormContent.ApplicantAccount;
            $.ajax({
              type: "post",
              async: false,
              url:
                KStarForm.bpmBaseUrl +
                "/AppicationForPurchase/SoftwarePurchaseApplicationIndex/SearchUserToApprove",
              data: { UserAD: userAccount, YWGrade: "" },
              dataType: "text",
              success: function (res) {
                arr = JSON.parse(JSON.parse(res).data);
              },
            });
            if (
              arr[0].GroupLeaderUserAccount == undefined &&
              arr[0].GroupLeaderUserAccount == null &&
              arr[0].GroupLeaderUserAccount == ""
            ) {
              _this.$message({ showClose: true, message: SubmitTip, type: "error" });
              return false;
            }
          } else {
            _this.$message({ showClose: true, message: SubmitTip, type: "error" });
            return false;
          }
        }
      }
      KStarForm.vmFormData.vmFormContent.Delegation =
        KStarForm.vmFormData.vmFormInstance.ApplicantDisplayName;
      KStarForm.vmFormData.vmFormContent.DelegationPosition =
        KStarForm.vmFormData.vmFormInstance.ApplicantPositionName;
      KStarForm.vmFormData.vmFormContent.DelegationDepartment =
        KStarForm.vmFormData.vmFormInstance.ApplicantOrgName;
      var now = new Date();
      var year = now.getFullYear(); //得到年份
      var month = now.getMonth(); //得到月份
      var date = now.getDate(); //得到日期
      var hour = now.getHours(); //得到小时
      var minu = now.getMinutes(); //得到分钟
      month = month + 1;
      if (month < 10) month = "0" + month;
      if (date < 10) date = "0" + date;
      if (hour < 10) hour = "0" + hour;
      if (minu < 10) minu = "0" + minu;
      var time = year + "-" + month + "-" + date + " " + hour + ":" + minu;
      KStarForm.vmFormData.vmFormContent.ApplyDate = time;
      KStarForm.vmFormData.vmFormContent.Submitter =
        KStarForm.vmFormData.vmFormInstance.SubmitterAccount;
      return true;
    }

    //表单审批前
    KStarForm.onApproveBefore = function () {
      if (KStarForm.vmFormData.vmUserLanguages == "en") {
        var SoftwareTypeTip = "The software type cannot be empty";
        var SoftwareNameTip = "The software name cannot be empty";
        var SoftwareVersionTip = "The software version cannot be empty";
        var InstallationPackageTip =
          "Whether there is an installation package cannot be empty";
        var ChargeTip = "Whether the charge cannot be empty";
        var LicenseQuotasTip = "The License quota cannot be empty";
        var PurchaseTimeTip = "The software purchase time cannot be empty";
        var ExpireDateTip = "The expiration time cannot be empty";
        var AvailabilityTip = "Software validity cannot be empty";
        var AttentionTip =
          "There are not enough remaining License quotas, please return to the purchase node to alert the library";
        var AttentionTip1 =
          "There are not enough remaining License quotas, please enter them in the software inventory record report";
      } else {
        var SoftwareTypeTip = "软件类型不能为空";
        var SoftwareNameTip = "软件名称不能为空";
        var SoftwareVersionTip = "软件版本不能为空";
        var InstallationPackageTip = "是否有安装包不能为空";
        var ChargeTip = "是否收费不能为空";
        var LicenseQuotasTip = "License配额不能为空";
        var PurchaseTimeTip = "软件采购时间不能为空";
        var ExpireDateTip = "到期时间不能为空";
        var AvailabilityTip = "软件有效性不能为空";
        var AttentionTip = "剩余License配额不足，请返回采购节点提醒入库";
        var AttentionTip1 = "剩余License配额不足，请在软件清单记录报表中录入";
      }
      if (KStarForm.vmFormData.vmFormType == "Approval") {
        if (KStarForm.vmFormData.vmOperation.ActivityName == "040_IT部门采购") {
          if (KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists.length >= 1) {
            if (
              !KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0].SoftwareType
            ) {
              KStarForm.VM.$message({
                showClose: true,
                message: SoftwareTypeTip,
                type: "error",
              });
              return false;
            }
            if (
              !KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0].SoftwareName
            ) {
              KStarForm.VM.$message({
                showClose: true,
                message: SoftwareNameTip,
                type: "error",
              });
              return false;
            }
            if (
              !KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0]
                .SoftwareVersion
            ) {
              KStarForm.VM.$message({
                showClose: true,
                message: SoftwareVersionTip,
                type: "error",
              });
              return false;
            }
            if (
              !KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0]
                .InstallationPackage
            ) {
              KStarForm.VM.$message({
                showClose: true,
                message: InstallationPackageTip,
                type: "error",
              });
              return false;
            }
            if (!KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0].Charge) {
              KStarForm.VM.$message({
                showClose: true,
                message: ChargeTip,
                type: "error",
              });
              return false;
            }
            if (
              !KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0].LicenseQuotas
            ) {
              KStarForm.VM.$message({
                showClose: true,
                message: LicenseQuotasTip,
                type: "error",
              });
              return false;
            }
            if (
              !KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0].PurchaseTime
            ) {
              KStarForm.VM.$message({
                showClose: true,
                message: PurchaseTimeTip,
                type: "error",
              });
              return false;
            }
            if (
              !KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0].ExpireDate
            ) {
              KStarForm.VM.$message({
                showClose: true,
                message: ExpireDateTip,
                type: "error",
              });
              return false;
            }
            if (
              !KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists[0].Availability
            ) {
              KStarForm.VM.$message({
                showClose: true,
                message: AvailabilityTip,
                type: "error",
              });
              return false;
            }
          }
        }
        if (KStarForm.vmFormData.vmOperation.ActivityName == "050_IT部确认") {
          if (
            (KStarForm.vmFormData.vmFormContent.SoftwareType == "2" ||
              KStarForm.vmFormData.vmFormContent.SoftwareType == "3") &&
            KStarForm.vmFormData.vmFormContent.Charge == "1"
          ) {
            var isAfterANode = false;
            for (var i = 0; i < KStarForm.vmFormData.vmFormApprovalHistorys.length; i++) {
              if (
                KStarForm.vmFormData.vmFormApprovalHistorys[i].ActivityName ==
                "040_IT部门采购"
              ) {
                isAfterANode = true;
                break;
              }
            }
            if (KStarForm.vmFormData.vmFormContent.DetailSPASoftwareListID) {
              var flag;

              $.ajax({
                type: "post",
                async: false,
                url:
                  "/AppicationForPurchase/SPASoftwareListReport/IsHaveRemainingAvailableQuotas",
                data: { id: KStarForm.vmFormData.vmFormContent.DetailSPASoftwareListID },
                dataType: "text",
                success: function (data) {
                  flag = data;
                },
              });
              if (flag == "False") {
                if (isAfterANode) {
                  KStarForm.VM.$message({
                    showClose: true,
                    message: AttentionTip,
                    type: "error",
                  });
                } else {
                  KStarForm.VM.$message({
                    showClose: true,
                    message: AttentionTip1,
                    type: "error",
                  });
                }
                return false;
              }
            } else {
              if (KStarForm.vmFormData.vmFormContent.SoftwareType == "2") {
                var obj = {};
                obj.SoftwareType = KStarForm.vmFormData.vmFormContent.SoftwareType;
                obj.SoftwareName = KStarForm.vmFormData.vmFormContent.SoftwareName;
                obj.SoftwareVersion = KStarForm.vmFormData.vmFormContent.SoftwareVersion;
                var flag;
                $.ajax({
                  type: "post",
                  async: false,
                  url: "/AppicationForPurchase/SPASoftwareListReport/IsHaveQuotas",
                  data: { model: obj },
                  dataType: "text",
                  success: function (data) {
                    flag = data;
                  },
                });
                if (flag == "False") {
                  if (isAfterANode) {
                    KStarForm.VM.$message({
                      showClose: true,
                      message: AttentionTip,
                      type: "error",
                    });
                  } else {
                    KStarForm.VM.$message({
                      showClose: true,
                      message: AttentionTip1,
                      type: "error",
                    });
                  }
                  return false;
                }
              }
            }
          }
        }
      }
      return true;
    };

    // KStarForm.bpmBaseUrl=  'http://localhost:8080';
    KStarForm.init(proxy, "CommonForm");

    return {
      formData,
      bpmform,
      FormContentModel,
    };
  },
  mounted: function () {
    var _this = this;
    //	部门
    axios
      .post(KStarForm.bpmBaseUrl + "/AppicationForPurchase/Common/GetDepcnameOrSiteMain")
      .then(function (res) {
        _this.depcnameArr = eval(res.data.data);
        //_this.depcnameArr.push({ "DeptName": "公共" })
      })
      .catch(function (error) {
        console.log(error);
      });
    //	公司
    axios
      .post(KStarForm.bpmBaseUrl + "/AppicationForPurchase/Common/GetCompanyList")
      .then(function (res) {
        _this.siteArr = eval(res.data.data);
      })
      .catch(function (error) {
        console.log(error);
      });
    //软件类型
    axios
      .post(
        KStarForm.bpmBaseUrl +
          "/AppicationForPurchase/common/getattributesinfo?typename=" +
          encodeURIComponent("软件类型") +
          "&columnname=" +
          ""
      )
      .then(function (res) {
        _this.softwareTypeArr = eval(res.data.data);
      })
      .catch(function (error) {
        console.log(error);
      });
    //软件有效性
    axios
      .post(
        KStarForm.bpmBaseUrl +
          "/AppicationForPurchase/common/getattributesinfo?typename=" +
          encodeURIComponent("软件有效性") +
          "&columnname=" +
          ""
      )
      .then(function (res) {
        _this.availabilityArr = eval(res.data.data);
      })
      .catch(function (error) {
        console.log(error);
      });
  },
  computed: {
    // 业务表单是否可以编辑控制
    /*
          Draft：草稿
          Application：申请
          Approval：审批
          Communicated：沟通（沟通出去后）
          CommunicateFeedback：沟通反馈页面
          ReApproval：重新提交
          View：查看
        **/
    isEdit: function () {
      return this.formData.vmFormType == "Application" ||
        this.formData.vmFormType == "Draft" ||
        this.formData.vmFormType == "ReApproval"
        ? true
        : false;
    },
    isdis: function () {
      this.isAgentDisable =
        KStarForm.vmFormData.vmFormContent.ISAgent == "1" ? false : true;
      return KStarForm.vmFormData.vmFormContent.ISAgent == "2" ? false : true;
    },
    isNodeDisable: function () {
      return KStarForm.vmFormData.vmOperation.ActivityName == "040_IT部门采购"
        ? false
        : true;
    },
  },
  watch: {
    "vmFormContent.scoopel": function (newValue, oldValue) {
      var _this = this;
      if (KStarForm.vmFormData.vmFormContent.scoopel.length <= 0) {
        _this.isScoopelHaveValue = true;
      } else {
        _this.isScoopelHaveValue = false;
      }
    },
    "vmFormContent.reportSPASoftwareLists": function (newValue, oldValue) {
      var _this = this;
      if (KStarForm.vmFormData.vmFormContent.reportSPASoftwareLists.length <= 0) {
        _this.IsDetailSPASoftwareListsAdd = true;
      } else {
        _this.IsDetailSPASoftwareListsAdd = false;
      }
    },
    "vmFormContent.SoftwareType": function (newValue, oldValue) {
      var _this = this;
      if (
        (newValue == 2 || newValue == 3) &&
        KStarForm.vmFormData.vmFormContent.Charge == 1
      ) {
        debugger;
        if (KStarForm.vmFormData.vmFormContent.IsEnoughLicence == true) {
          _this.isBudgetNumberHidden = true;
        } else {
          _this.isBudgetNumberHidden = false;
        }
      } else {
        _this.isBudgetNumberHidden = true;
      }
    },
    "vmFormContent.Charge": function (newValue, oldValue) {
      var _this = this;
      if (
        (KStarForm.vmFormData.vmFormContent.SoftwareType == 2 ||
          KStarForm.vmFormData.vmFormContent.SoftwareType == 3) &&
        newValue == 1
      ) {
        debugger;
        if (KStarForm.vmFormData.vmFormContent.IsEnoughLicence == true) {
          _this.isBudgetNumberHidden = true;
        } else {
          _this.isBudgetNumberHidden = false;
        }
      } else {
        _this.isBudgetNumberHidden = true;
      }
    },
  },
};
</script>

<style>
#app {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}

#TabDiv .el-form-item__label {
  width: 700px !important;
  /*            font-weight: bold !important;
    text-align: center !important;*/
}
</style>

<style>
#app {
  /* font-family: Avenir, Helvetica, Arial, sans-serif; */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}

body {
  background-color: #f5f8fd;
}

@media (min-width: 1200px) {
  .center {
    width: 1200px;
    margin: 0 auto;
  }
}

@media (max-width: 767px) {
  .pc-top-interval {
    display: none;
  }
}
</style>

<style>
.el-form--label-left .el-form-item__label {
  text-indent: 15px !important;
}

#TabDiv .el-form-item__label {
  width: 700px !important;
  /*            font-weight: bold !important;
  text-align: center !important;*/
}

.el-table__body-wrapper .el-input--mini .el-input__inner {
  border: none;
}

.el-table__body-wrapper .el-form-item--mini.el-form-item,
.el-form-item--small.el-form-item {
  margin-bottom: 0px;
}

.el-table__body-wrapper .el-select .el-input.is-focus .el-input__inner {
  border: none;
}

.el-table__body-wrapper .el-input--suffix .el-input__inner {
  border: none;
}

.el-table__body-wrapper .el-input--mini .el-input__inner {
  height: 28px !important;
  line-height: 28px !important;
}

.el-form-item__label {
  /* 字体大小 */
  font-size: 13px;
  /* 字体超出隐藏变省略号 */
  overflow: hidden;
  text-overflow: ellipsis;
  /* 不换行 */
  white-space: nowrap;
}

.add {
  height: 30px;
  color: rgb(170, 170, 170) !important;
  background: #fff;
  text-align: center;
  cursor: pointer;
  line-height: 30px;
  font-size: 12px !important;
  border: 1px dashed #ccc;
}

.add:hover {
  background: rgb(235, 245, 255);
  color: #409eff !important;
}

.box {
  margin-top: 40px;
}

.TLFormCss .view-body .el-form-item__label {
  line-height: 40px !important;
}

.TLFormCss .view-body .el-form-item__content {
  line-height: 40px !important;
}

.TLFormCss .view-body .el-form-item__content {
  flex: none !important;
  margin-left: 155px !important;
}

.TLFormCss .el-form-item__label {
  line-height: 40px !important;
}

.TLFormCss .el-form-item__content {
  line-height: 40px !important;
}

.TLFormCss .el-form-item__content {
  flex: none !important;
  margin-left: 155px !important;
}

.TLFormCssFooter {
  padding: 20px 20px 10px;
  text-align: right;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
.groupMembers {
  display: flex;
  justify-content: space-between;
  margin: 20px 0;

  div {
    display: flex;
  }

  span {
    margin-right: 40px;
    cursor: pointer;
    color: #00abd5;
  }

  p {
    display: inline-block;
    cursor: pointer;
    color: #00abd5;
  }
}
</style>
